﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Support.V4.Widget;
using Android.Views;
using Android.Widget;
using static Android.Support.V4.Widget.SwipeRefreshLayout;

namespace Medicine.Core.Listeners
{
    public class SwipeRefreshLayoutOnRefreshListener : Java.Lang.Object, IOnRefreshListener
    {
        private ListView _listView;
        private SwipeRefreshLayout _sender;


        public SwipeRefreshLayoutOnRefreshListener(object sender,ListView listView)
            : base(JNIEnv.StartCreateInstance("mono/android/support/v4/widget/SwipeRefreshLayout_OnRefreshListenerImplementor", "()V"), JniHandleOwnership.TransferLocalRef)
        {
            JNIEnv.FinishCreateInstance(base.Handle, "()V");
            this._sender = sender as SwipeRefreshLayout;
            this._listView = listView;
        }

        public void OnRefresh()
        {
            ((this._listView.Adapter) as BaseAdapter).NotifyDataSetChanged();
            this._sender.Refreshing = false;
        }
    }
}